package com.copa.l2319;

/**
 * @author copa
 * @createDate 2023-01-31 6:29
 * @function 暴力法
 */
public class Test1 {

    public boolean checkXMatrix(int[][] grid) {
        int gridLength = grid.length;
        for (int i = 0; i < gridLength; i++) {
            for (int j = 0; j < gridLength; j++) {
                if (!(j == i || j == gridLength - 1 - i) && grid[i][j] != 0) {
                    return false;
                }
                if (grid[i][i] == 0 || grid[i][gridLength - 1 - i] == 0) {
                    return false;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        int[][] grid = {{2,0,0,1},{0,3,1,0},{0,5,2,0},{4,0,0,2}};
        //int[][] grid = {{5,7,0},{0,3,1},{0,5,0}};
        System.out.println(new Test1().checkXMatrix(grid));
    }
}
